<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信审添加与客户、供应商、挂靠公司有相关的人员</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
				<form id="formSet_cstManualRelation"  style="overflow: visible;">
					<div class="fieldset1 tabel_col clearFix">
					<input name="sId" id="sId" type="hidden" value="${cstManualRelation.id}">
			            <div class="fieldBox col_50">
			                <div class="label"> 姓名</div>
			                <div class="field">
			                    <input name="relaNm" id="relaNm" type="text" class="ui-textbox" value="${cstManualRelation.relaNm}" validate="{required:true}">
			                </div>
			                <span class="requiredSymbol" style="display: none" >*</span>
			            </div>
			            <div class="fieldBox col_50">
			                <div class="label"> 手机号</div>
			                <div class="field">
			                    <input name="relaPhone" id="relaPhone" type="text" class="ui-textbox" value="${cstManualRelation.relaPhone}" validate="{maxlength:20,mobile:true}">
			                </div>
			                <span class="requiredSymbol" style="display: none" >*</span>
			            </div>

						<div class="fieldBox col_50">
							<div class="label">证件类型</div>
							<div class="field">
								<select name="certType" id="certType" data-value=" "  validate="{required:true,select:true}">
									<option value=" " checked>请选择</option>
									<option value="2" >组织机构代码</option>
									<option value="1">身份证</option>
								</select>
							</div>
						</div>

			            <div class="fieldBox col_50">
			                <div class="label"> 证件号码</div>
			                <div class="field">
			                    <input name="certNo" id="certNo" type="text" class="ui-textbox" value="${cstManualRelation.certNo}" validate="{required:true}">
			                </div>
			                <span class="requiredSymbol" style="display: none" >*</span>
			            </div>
						<div class="fieldBox col_50">
							<div class="label">联系人类型</div>
							<div class="field">
								<input name="relaUserTypeCd" id="relaUserTypeCd" placeholder="请选择" ltype="combobox" validate="{required:true}">
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_100">
							<div class="label">备注</div>
							<div class="field" style="width: 100%;">
								<textarea name="relaNote" id="relaNote" rows="4" class="l-textarea" style="width:99%" >${cstManualRelation.relaNote}</textarea>
							</div>
						</div>
					</div>
				<%--	<div id='zk_02' class="btnsBox">
						<span id="saveBtn" class="sq-button sq-button-round">保存</span>
					</div>--%>
				</form>

		</div>
<script type="text/javascript">
var args='${args}';
var cstId='${cstId}';
var useType='${useType}';
var cstType='${cstType}';
var certType='${cstManualRelation.certType}';
var relaUserTypeCd = "${cstManualRelation.relaUserTypeCd}";
var  id='${cstManualRelation.id}'
$(function(){

    $("#relaUserTypeCd").ligerComboBox({
        valueField: 'key',
        textField: 'value'
    });
    liger.get("relaUserTypeCd").setData(${relaUserTypeCdListJson});
    var relaUserTypeCdNm = "${cstManualRelation.relaUserTypeCdNm}";
    $("#relaUserTypeCd").val(relaUserTypeCdNm);
    $("#relaUserTypeCd").selected = true;
    //初始化ligerForm
	var formSet1 = $('#formSet_cstManualRelation').ligerForm({
        validate : true
	});

	if(args==4){
    //新增
	}else{
		//设置初始值
		var form = liger.get("formSet_cstManualRelation");
		form.setData({
			certType:certType,
		});
	}
    //保存
/*	$("#saveBtn").click(function(event) {
	    var form = liger.get("formSet_cstManualRelation");
	    //验证
	    if (!form.valid()) {
	    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false; //验证不通过，不执行以下代码
        }
		//拿到页面数据
		var data = form.getData();

		if(data.certType==1){
			var ref = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;//身份证 正则
			if (!ref.test(data.certNo)) {
				top.$.ligerDialog.SQalert({content: "请输入正确的身份证格式", SQ_type: "warning"});
				return false;
			}
		}


		if(args==4){
			var url = '<%=path%>/customer/cstManualRelation/add.do';
			data["cstId"]= cstId;//赋值返回的id主键
			data["useType"]= useType;
		}else{
			if(id != ""){
				url = '<%=path%>/customer/cstManualRelation/modify.do';
				data["id"]= id;//赋值返回的id主键
			}
		}
       var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 /!* 父级的弹出框关闭 *!/
					 parent.grid.reload();
					 frameElement.dialog.close();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
		
	});*/

});

//定义父级调用事件
frameElement.dialog.onOk = function () {
    save();
}

frameElement.dialog.onCancel = function () {
    frameElement.dialog.close();
}


//保存
function save(){
	var form = liger.get("formSet_cstManualRelation");
	//验证
	if (!form.valid()) {
		$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
		return false; //验证不通过，不执行以下代码
	}
	//拿到页面数据
	var data = form.getData();
    if (data.relaUserTypeCd == null || data.relaUserTypeCd == '') {
        data["relaUserTypeCd"] = relaUserTypeCd;
    }
	if(data.certType==1){
		var ref = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;//身份证 正则
		if (!ref.test(data.certNo)) {
			top.$.ligerDialog.SQalert({content: "请输入正确的身份证格式", SQ_type: "warning"});
			return false;
		}
	}
	var url='';
	if(args==4){
		var url = '<%=path%>/customer/cstManualRelation/add.do';
		data["cstId"]= cstId;//赋值返回的id主键
		data["useType"]= useType;
		data["cstType"]= cstType;
	}else{
		if(id != ""){
			url = '<%=path%>/customer/cstManualRelation/modify.do';
			data["id"]= id;//赋值返回的id主键
		}
	}




	AjaxUtils.ajaxPost(url, data, addCallback);
}


//新增回调
function addCallback(msg){
	if(msg.success == 1){
        parent.liger.get('ligergridDB').reload()
		UIUtils.alertSuccess("操作成功!");
		frameElement.dialog.close();
	}else{
		UIUtils.alertError(msg.info);
	}
}

//修改初始化数据
/*function initData(){
	var dataId = $("#dataId").val();
	if(StringUtils.isEmpty(dataId))return;
	var _url = ' <%=path%>/demo/demo/getById.do';
	AjaxUtils.ajaxGet(_url, {id:dataId}, initCallback);
}*/





</script>
</body>
</html>
